<?php
declare (strict_types = 1);

namespace app\common\customer\model;

use app\common\config\logic\DictionaryLogic;
use app\common\config\logic\RegionLogic;
use app\common\system\logic\UserLogic;
use think\Model;
use think\model\concern\SoftDelete;

class UploadFile extends Model
{
    protected $table = "tk_upload_file";
    
    use SoftDelete;
    protected $defaultSoftDelete = 0;

    public function getUserAttr($value, $data) {
        $userLogic = new UserLogic();
        $user = $userLogic->getUser($data['user_id']);

        return $user;
    }

    // 获取渠道
    public function getSourceAttr($value, $data) {
        if(empty($data['source_id'])) return '';
        $logic = new DictionaryLogic();
        return $logic->getFullPath($data['source_id']);
    }

    // 获取城市
    public function getCityAttr($value, $data) {
        if(empty($data['city_id'])) return '';
        $logic = new RegionLogic();
        return $logic->getRegion($data['city_id'], ['id','name','short_name']);
    }

}
